<form action="{:sysuri()}" autocomplete="off" class="layui-form layui-form-pane form-search" method="get" onsubmit="return false">

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">用户编号</label>
        <label class="layui-input-inline">
            <input class="layui-input" name="code" placeholder="请输入用户编号" value="{$get.code|default=''}">
        </label>
    </div>

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">绑定手机</label>
        <label class="layui-input-inline">
            <input class="layui-input" name="phone" placeholder="请输入绑定手机" value="{$get.phone|default=''}">
        </label>
    </div>

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">姓名昵称</label>
        <label class="layui-input-inline">
            <input class="layui-input" name="username" placeholder="请输入姓名昵称" value="{$get.username|default=''}">
        </label>
    </div>

    <!--{notempty name='upgrades'}-->
    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">用户等级</label>
        <div class="layui-input-inline">
            <select class="layui-select" name="level_code">
                <option value="">-- 全部 --</option>
                {foreach $upgrades as $upgrade}{if input('level_code') eq $upgrade.number.''}
                <option selected value="{$upgrade.number|default=0}">[ VIP{$upgrade.number|default='0'} ] {$upgrade.name|default=''}</option>
                {else}
                <option value="{$upgrade.number|default=0}">[ VIP{$upgrade.number|default='0'} ] {$upgrade.name|default=''}</option>
                {/if}{/foreach}
            </select>
        </div>
    </div>
    <!--{/notempty}-->

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">绑定时间</label>
        <div class="layui-input-inline">
            <input class="layui-input" data-date-range name="create_at" placeholder="请选择绑定时间" value="{$get.create_at|default=''}">
        </div>
    </div>

    <div class="layui-form-item layui-inline">
        <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
        <button class="layui-btn layui-btn-primary" data-form-export="{:url('index')}?type={$type|default='index'}" type="button">
            <i class="layui-icon layui-icon-export"></i> 导 出
        </button>
    </div>
</form>

<script>
    require(['excel'], function (excel) {
        excel.bind(function (data) {

            // 设置表格内容
            data.forEach(function (item, index) {
                data[index] = [
                    {v: item.unid, t: 'n'},
                    item.user.code || '-',
                    item.user.username || '-',
                    item.user.nickname || '-',
                    item.user.phone || '-',
                    item.user.email || '-',
                    'VIP' + (item.level_code || '0') + ' ' + (item.level_name || ''),
                    item.user.create_time || '',
                ];
            });

            // 设置表头内容
            data.unshift(['ID', '用户编号', '用户姓名', '用户昵称', '绑定手机', '绑定邮箱', '用户等级', '绑定时间']);

            // 应用表格样式
            return this.withStyle(data, {H: 120});

        }, '用户账号数据' + layui.util.toDateString(Date.now(), '_yyyyMMdd_HHmmss'));
    });
</script>
